python libs for all vis things


In [6]:
%matplotlib inline
import pandas as pd
import numpy as np

from ipywidgets import interact
import matplotlib.pyplot as plt, mpld3
import seaborn as sns

d3.js via mpld3


In [7]:
mpld3.enable_notebook()

In [8]:
mean, cov = [0, 1], [(1, .5), (.5, 1)]
data = np.random.multivariate_normal(mean, cov, 200)
df = pd.DataFrame(data, columns=["x", "y"])

scatter_sns = sns.jointplot(x="x", y="y", data=df)
fig = plt.gcf()

ax = plt.gca()
pts = ax.get_children()[3]

mpld3.plugins.connect(fig)

mpld3.display(fig)


Out[8]:

In [9]:
t = np.arange(0.0, 1.0, 0.01)

y1 = np.sin(2*np.pi*t)
y2 = np.sin(2*2*np.pi*t)

data = pd.DataFrame({"t": t,
                     "y1": y1,
                     "y2": y2,
                     "size": np.random.randint(20,200, size=len(t))
                     })


scatter_1 = sns.lmplot("t", "y1", 
           scatter_kws={"s": data["size"]},
           robust=False, # slow if true
           data=data, size=8)

fig1 = plt.gcf()
ax1 = plt.gca()
pts1 = ax1.get_children()[3]

scatter_2 = sns.lmplot("t", "y2", 
           scatter_kws={"s": data["size"]},
           robust=False, # slow if true
           data=data, size=8)

fig2 = plt.gcf()
ax2 = plt.gca()
pts2 = ax2.get_children()[3]

#mpld3.plugins.connect(fig2)

#mpld3.display(fig2)



In [10]:
# Scatter points
fig, ax = plt.subplots()
np.random.seed(42)
x, y = np.random.normal(size=(2,200))
color, size = np.random.random((2,200))

ax.scatter(x, y, c=color, s = 500 * size, alpha=0.3)
ax.grid(color='lightgray', alpha=0.7)


others to check out